//
//  RefreshVoltage.m
//  CarCare
//
//  Created by ileo on 15/5/12.
//  Copyright (c) 2015年 baozun. All rights reserved.
//

#import "RefreshVoltage.h"
#import "NetSetting.h"

@implementation RefreshVoltage

IMP_SINGLETON

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.timeInterval = 10800;
        __weak __typeof(self) wself = self;
        self.Refresh = ^(){
            [[NetSetting currentVoltageValue] requestSuccess:^(id JSON) {
                wself.minVoltage = [JSON[@"minVoltage"] floatValue];
                wself.minVoltageTime = JSON[@"minTime"];
                wself.currentVoltage = [JSON[@"curVoltage"] floatValue];
                
                if (wself.currentVoltage < wself.minVoltage && wself.currentVoltage != 0) {
                    wself.minVoltage = wself.currentVoltage;
                }
                
                if (wself.RefreshCallBack) {
                    wself.RefreshCallBack(JSON);
                }
            }];
        };
    }
    return self;
}

@end
